<?php

/**
 * Description of Login
 *
 * @author Suraj
 */
/*class Form_Login extends Zend_Form
{
	public function __construct()
	{
		parent::__construct();
		$this->setName('UserLogin');
		$userName = new Zend_Form_Element_Text('userName');
		$userName->setLabel('User Name')
				->setRequired(true)
				->addFilter('StripTags')
				->addFilter('StringTrim')
				->addValidator('NotEmpty');
		$password = new Zend_Form_Element_Password('password');
		$password->setLabel('Password')
				->setRequired(true)
				->addFilter('StripTags')
				->addFilter('StringTrim')
				->addValidator('NotEmpty');
		$submit = new Zend_Form_Element_Submit('submit');
		$redirect = new Zend_Form_Element_Hidden('redirect');
		$submit->setAttrib('id', 'submitbutton');

        $login_form = new Zend_form();
        $login_form->setAction("index","index")
                    ->setMethod("post")
                    ->addElement($userName)
                    ->addElement($password)
                    ->addElement($submit);
		$this->addElements( array ( $userName, $password, $submit));
	}
}
*/
 class Form_Login extends Zend_form {
    public function __construct() {

    parent::__construct();

    // Create and configure username element:
    $username = $this->createElement('text', 'userName');
    $username->addValidator('alnum')
             ->setLabel('UserName')
             ->addValidator('regex', false, array('/^[a-z]+/'))
             ->addValidator('stringLength', false, array(4, 20))
             ->setRequired(true)
             ->addFilter('StringToLower');

    // Create and configure password element:
    $password = $this->createElement('password', 'password');
    $password->addValidator('StringLength', false, array(4))
             ->setLabel('Password')
             ->setRequired(true);

    // Add elements to this:
    $this->addElement($username)
         ->addElement($password)
         // use addElement() as a factory to create 'Login' button:
         ->addElement('submit', 'login', array('label' => 'Login'));   
    }
}